/**
 * 
 */
package net.sf.cldsql.sql2json.demo;

import net.sf.cldsql.dj.db.QueryProxy;
import net.sf.cldsql.dj.mvc.ConnTransAop;
import net.sf.cldsql.dj.utl.Codelet;
import net.sf.cldsql.sql2json.main.SjSetup;

/**
 * SjSetupImpl
 */
public class SjDemoSetupImpl extends SjSetup {

    @Override
    public boolean build() {
        
        container.register(SjDemoQuery.class, new Class[] {ConnTransAop.class}, "exec.*", new Codelet() {
            public Object run(Object... args) {
                return new QueryProxy<SjDemoQuery>(SjDemoQuery.class).newInstance();
            }});

        final String sjDemoService = container.register(SjDemoService.class, SjDemoServiceImpl.class, new Class[] {ConnTransAop.class}, "exec.*");
        controller.register("GET", "^/echo$", sjDemoService, "execEcho");
        controller.register("POST", "^/echo$", sjDemoService, "execEcho");
        
        controller.register("GET", "^/test/([^/]+)$", sjDemoService, "execGet");
        controller.register("GET", "^/test$", sjDemoService, "execGetAll");
        controller.register("PUT", "^/test$", sjDemoService, "execPut");
        controller.register("POST", "^/test/([^/]+)$", sjDemoService, "execPost");
        controller.register("DELETE", "^/test/([^/]+)$", sjDemoService, "execDelete");
        
        return true;
    }

}
